package com.shop.cereshop.commons.tencent.moderation.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @description: 视频任务管理器
 * @author zdd
 * @date 2025/10/26 23:58
 * @version 1.0
 */
@Slf4j
@Component
public class VideoTaskManager {


    private final Map<String, VideoTaskInfo> taskMap = new ConcurrentHashMap<>();

    public void addTask(String taskId, String videoUrl) {
        VideoTaskInfo taskInfo = new VideoTaskInfo(taskId, videoUrl, System.currentTimeMillis());
        taskMap.put(taskId, taskInfo);
        log.info("添加视频审核任务, taskId: {}, videoUrl: {}", taskId, videoUrl);
    }

    public VideoTaskInfo getTask(String taskId) {
        return taskMap.get(taskId);
    }

    public void removeTask(String taskId) {
        taskMap.remove(taskId);
        log.info("移除视频审核任务, taskId: {}", taskId);
    }

    public static class VideoTaskInfo {
        private String taskId;
        private String videoUrl;
        private long createTime;

        public VideoTaskInfo(String taskId, String videoUrl, long createTime) {
            this.taskId = taskId;
            this.videoUrl = videoUrl;
            this.createTime = createTime;
        }

        // getters and setters
        public String getTaskId() { return taskId; }
        public String getVideoUrl() { return videoUrl; }
        public long getCreateTime() { return createTime; }
    }



}
